class Solution(object):
    def maximalSquare(self, matrix):
        """
        :type matrix: List[List[str]]
        :rtype: int
        """
        if len(matrix) == 0:
            return 0

        for row in matrix:
            for c, value in enumerate(row):
                if value == '0':
                    row[c] = 0
                else:
                    row[c] = 1
        

        for r in range(1, len(matrix)):
            for c in range(1, len(matrix[0])):
                matrix[r][c] = max(matrix[r-1][c], matrix[r][c-1], matrix[r-1][c-1]) + 1
        return matrix[-1][-1]